{template header}
<script src="static/bootstrap/js/utils.js"></script>
<style>
    .name_list{
        top:30px; position: absolute; width: 206px; max-height: 100px; overflow-y:scroll; left: 156px;
        background: #fff ; border: 1px solid #ccc; padding: 5px;
        display: none;
    }

    .name_list li { height: 30px; line-height: 30px; }
    .name_list li:hover{background-color: beige}
    .name_list li img { width: 30px; height: 30px; margin-right: 5px;font-size: 4px; }
    .pr {position: relative; }
</style>
<link rel="stylesheet" href="static/calendar/js/calendar.css" />
<script type="text/javascript" charset="utf-8" src="static/calendar/calendar.php"></script>
<script type="text/javascript">
    function checkUer(uid)
    {
        uid = $("#uid").val();
        if(Utils.isEmpty(uid)){
            $("#name_list").hide();
            return false;
        }
        $.ajax({url:"index.php?c=admin&a=getUser&uid=" + uid ,
            async:false,
            dataType:"json",
            error:function(){
                alert('未知错误');
            },
            success:function(data, status){
                $('#name_list').show();
                var info = data.data;
                var html='';

                if(data.message == ''){
                    for(var i in info){
                        html += "<li onclick='fillUid(this)' id='"+info[i].uid+"'>";
                        if(info[i].header.length != 0){
                            html += '<img src="'+info[i].header+'" alt="头像">';
                        }
                        html += info[i].nickname+"</li>";
                    }
                }
                if(html != ''){
                    $("#name_list").html(html);
                }else{
                    $("#name_list").hide();
                }
            }
        });
        return false;
    }
    function checkSubmit(frm)
    {
        var uid = frm.uid.value;
        var comment_content = frm.comment_content.value;

        var mess = '';
        if(Utils.isEmpty(uid)) {
            mess = mess + '用户ID不能为空\n';
        }
        if(Utils.isEmpty(comment_content)) {
            mess = mess + '评论内容不能为空\n';
        }
        if(!Utils.isEmpty(mess))
        {
            alert(mess);
            return false;
        }
        return true;
    }
    function fillUid(obj){
        $('#uid').val(obj.id);
        $("#name_list").hide();
    }
</script>
<form enctype="multipart/form-data" class="form-horizontal" action="index.php?c=admin&a=addNewsComment&type=insert" method="post" name="commentForm" onsubmit="return checkSubmit(this)">
    <div class="control-group pr">
        <label class="control-label" for="inputTiltle">用户ID：</label>
        <div class="controls">
            <input type="text" AutoComplete="off" name='uid' id="uid" placeholder="请输入用户ID" value="" onkeyup="checkUer(this.value)">
            <ul style="cursor: pointer" class="name_list" id="name_list">
            </ul>
        </div>
    </div>
    <div class="control-group">
        <label class="control-label" for="inputShortDesc">评论内容：</label>
        <div class="controls">
            <textarea name="comment_content" placeholder="请输入评论" style="min-width:80%; min-height:200x;"></textarea>
        </div>
    </div>

    <div class="control-group">
        <label class="control-label" for="inputShortDesc">评论图：</label>
        <div class="controls">
            <input type="file" name="comment_img" value="">
        </div>
    </div>
    <div class="control-group">
        <label class="control-label" for="inputaddtime">设置添加时间：</label>
        <div class="controls">
            <input type="text" name="add_time" readonly="readonly" id="add_time_id" value="{eval echo date('Y-m-d H:i:s')}">
            <input name="add_time_btn" type="button" id="add_time_btn" onclick="return showCalendar('add_time_id', '%Y-%m-%d %H:%M:%S', '24', false, 'add_time_btn');" value="选择" class="button" id="add_time_id"/>
        </div>
    </div>
    <div class="control-group">
        <div class="controls">
            <input type="hidden" name="tid" value="{$uid}">
            <input type="hidden" name="name" value="{$nickname}">
            <input type="hidden" name="news_id" value="{$news_id}">
            <input type="hidden" name="father_id" value="{$father_id}">
            <button type="submit" class="btn">添加</button>
        </div>
    </div>
</form>
{template footer}